<?php
	$slbUserGroup	= $this->formSelect('group_id',$this->Item['group_id'],array(),$this->slbUserGroup);
	$slbChucvu 		= $this->formSelect('id_chucvu',$this->Item['id_chucvu'],array(),$this->slbChucvu);
	$slbPhongban	= $this->cmsSelect('id_phongban',$this->Item['id_phongban'],$this->slbPhongban,array());
	$slbCoso 		= $this->formSelect('id_coso',$this->Item['id_coso'],array(),$this->slbCoso);
?>
<fieldset class="adminField">
	<legend>Bộ lọc</legend>
	<div class="fieldContent">
		<table>
			<tr>
				<td>
					<div class="label">Chọn nhóm</div>
					<?php echo $slbUserGroup;?>
				</td>
				<td>
					<div class="label">Chức vụ</div>
					<?php echo $slbChucvu;?>
				</td>
				<td>
					<div class="label">Phòng ban</div>
					<?php echo $slbPhongban;?>
				</td>
				<td>
					<div class="label">Cơ sở</div>
					<?php echo $slbCoso;?>
				</td>
			</tr>
		</table>
	</div>
</fieldset>
<div class="contentPopup">
	<div class="left">
		<fieldset class="adminField">
			<legend>Danh sách</legend>
			<div id="loadUser"></div>
			<script type="text/javascript">
				$('#loadUser').css({'height': '200px;'}).addClass('dangtai2').load('<?php echo $this->baseUrl('default/ajax/load-user');?>', function(){ $(this).removeClass('dangtai2'); });

				function chonUser(idUser, name, phongban_name, chucvu_name){
					if($('#tblDaChon tr#' + idUser).length > 0){
						alert('Nhân viên này đã được chọn');
					}else{
						if($('#tblDaChon tr').length > 0){
							$('#tblDaChon tr:last').after('<tr id="'+idUser+'"><td id="name"><a href="javascript:coid(0)" title="'+ chucvu_name + ' - ' + phongban_name +'">' + name + '</td><td align="center"><a href="javascript:void(0)" onclick="xoaChonUser('+idUser+')">Xóa</a></td></tr>');
						}else{
							$('#tblDaChon').append('<tr><th>Họ tên</th><th style="text-align: center;"><a href="javascript:void(0)" onclick="xoaChonUserAll()">Xóa tất cả</a></th></tr>');
							$('#tblDaChon tr:last').after('<tr id="'+idUser+'"><td id="name"><a href="javascript:coid(0)" title="'+ chucvu_name + ' - ' + phongban_name +'">' + name + '</td><td align="center"><a href="javascript:void(0)" onclick="xoaChonUser('+idUser+')">Xóa</a></td></tr>');
						}
					}
				}

				function chonUserAll(){
					if($('#tblDaChon tr').length <= 0){
						$('#tblDaChon').append('<tr><th>Họ tên</th><th style="text-align: center;"><a href="javascript:void(0)" onclick="xoaChonUserAll()">Xóa tất cả</a></th></tr>');
						$('#tableListUser tr').each(function(index){
							if(index > 0){
								$('#tblDaChon tr:last').after('<tr id="'+$(this).attr('id')+'"><td id="name"><a href="javascript:coid(0)" title="'+ $('#chucvu_name', this).text() + ' - ' + $('#phongban_name', this).text() +'">' + $('#name', this).text() + '</td><td align="center"><a href="javascript:void(0)" onclick="xoaChonUser('+$(this).attr('id')+')">Xóa</a></td></tr>');
							}
						});
					}else{
						$('#tableListUser tr').each(function(index){
							if(index > 0){
								//alert($(this).attr('id'));
								if($('#tblDaChon tr#' + $(this).attr('id')).length <= 0){
									$('#tblDaChon tr:last').after('<tr id="'+$(this).attr('id')+'"><td id="name"><a href="javascript:coid(0)" title="'+ $('#chucvu_name', this).text() + ' - ' + $('#phongban_name', this).text() +'">' + $('#name', this).text() + '</td><td align="center"><a href="javascript:void(0)" onclick="xoaChonUser('+$(this).attr('id')+')">Xóa</a></td></tr>');
								}
							}
						});
					}
				}

				function xoaChonUser(idUser){
					$('#tblDaChon tr#' + idUser).remove();
					if($('#tblDaChon tr').length == 1){
						$('#tblDaChon tr').remove();
					}
				}

				function xoaChonUserAll(){
					$('#tblDaChon tr').remove();
				}
			</script>
		</fieldset>
	</div>
	<div class="right">
		<fieldset class="adminField">
			<legend>Danh sách đã chọn</legend>
			<div style="height: 372px; overflow: auto;">
				<table class="tableTeam1" id="tblDaChon"></table>
			</div>
		</fieldset>
	</div>
</div>